package com.qingrongby.shop.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.apache.commons.lang.StringUtils;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.util.HashMap;
import java.util.Map;

/**
 * @CLASSNAME CovertyArrayAndJson
 * @DESCRIPTION TODO
 * @AUTHOR hzp
 * @DATE 2020/6/29
 * @VERSION 1.0
 **/
public class ConverterTAndJson{
    public static <T> String objectToString(T t){
        if (t==null){
            return "";
        }
        return JSON.toJSONString(t);
    }
    public static<T> T stringToObject(String s, TypeReference<T> typeReference){
        T t=JSON.parseObject(s,typeReference);
        return t;
    }
}
